<?php
/**
 * Joomla! 1.5 component NS Pro
 *
 * @version $Id: view.html.php 2009-04-28 01:47:12 svn $
 * @author Christopher Mavros
 * @package Joomla
 * @subpackage NS Pro
 * @license GNU/GPL
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class NsproViewFieldedit extends JView {

    function display($tpl = null)
    {

        $model  =& $this->getModel();
        $mfield   = $model->getField();
        $isNew  = ($mfield->id < 1);

        $state =& $this->get( 'state' );
        $olists['order_Dir'] = $state->get( 'filter_order_Dir' );
        $ftypes = $state->get( 'ftypes' );
        $this->assignRef('ftypes', $ftypes);

        $text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
        $jversion = new JVersion();
        $j15 = ($jversion->RELEASE == '1.5');
        if ($j15 == true) {
          JToolBarHelper::title(   JText::_( 'Additional Fields' ).': <small><small>[ ' . $text.' ]</small></small>', 'fields.png' );
        }
        else {
          JToolBarHelper::title(   JText::_( 'Additional Fields' ).': <small><small>[ ' . $text.' ]</small></small>', 'levels-add.png' );
        }
        JToolBarHelper::save('fsave');
        if ($isNew)  {
            JToolBarHelper::cancel('fcancel');
        } else {
            JToolBarHelper::cancel( 'fcancel');
        }

        $this->assignRef('field', $mfield);
        $this->assignRef('isNew', $isNew);

        $db =& JFactory::getDBO();
        $query = 'SELECT MAX(`ordering`) FROM `#__nspro_fields`';
        $db->setQuery($query);
        $maxorder = $db->loadRow();
        $maxordering = $maxorder[0]+1;
        $this->assignRef('maxorder', $maxordering);

        parent::display($tpl);
    }
}
?>